package src;

public class StaticProxy {
    public static void main(String[] args) {
        WeddingCompany weddingCompany = new WeddingCompany(new You());
        weddingCompany.happyMarry();
    }
}
//接口Marry
interface Marry {
    void happyMarry();
}
//You类 实现 Marry接口，重写happyMarry的关于我的具体方法
class You implements Marry{
    @Override
    public void happyMarry() {
        System.out.println("我结婚");
    }
}
//代理：WeddingCompany类 实现Marry接口，重写happyMarry方法的同时传入我的方法（？不太会描述）
class WeddingCompany implements Marry{
    private Marry target;

    //重写构造方法，写入参数
    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void happyMarry() {
        before();
        this.target.happyMarry();
        after();
    }

    private void before() {
        System.out.println("结婚前准备");
    }

    private void after() {
        System.out.println("结婚后收钱");
    }
}
